<template>
    <div>
    <!-- 表头 -->
    <el-page-header @back="goBack" :content="content"> </el-page-header>
    <!-- 表数据 -->
    <!-- {{form}} -->
    <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="文章编号">
            <el-input v-model="form.id"></el-input>
        </el-form-item>
        <el-form-item label="文章标题">
            <el-input v-model="form.title"></el-input>
        </el-form-item>
        <el-form-item label="文章简要">
            <el-input v-model="form.brief"></el-input>
        </el-form-item>
        <el-form-item label="作者编号">
            <el-input v-model="form.authorId"></el-input>
        </el-form-item>
        <el-form-item label="创建编号">
            <el-input v-model="form.categoryId"></el-input>
        </el-form-item>
        <!-- <el-form-item label="活动时间">
            <el-col :span="11">
            <el-date-picker type="date" placeholder="选择日期" v-model="form.publishTime" style="width: 100%;"></el-date-picker>
            </el-col> -->
            <!-- <el-col class="line" :span="2">-</el-col>
            <el-col :span="11">
            <el-time-picker placeholder="选择时间" v-model="form.date2" style="width: 100%;"></el-time-picker>
            </el-col> -->
        <!-- </el-form-item> -->
        <!-- <el-form-item label="文章简要">
            <el-input type="textarea" v-model="form.brief"></el-input> 
        </el-form-item> -->
        <el-form-item label="文章内容">
            <el-input type="textarea" v-model="form.content"></el-input>
        </el-form-item>
        <el-form-item>
            <div style="text-align:right">
            <el-button type="primary" @click="submitHandler">提交</el-button>
            </div>
        </el-form-item>
        </el-form>
    </div>
</template>
<script>
import { post } from '@/utils/request'
export default {
    data(){
        return {
            content:"新增文章数据",
            form:{}
        }
    },
    methods: {

        // 提交
        submitHandler(){
        let url = "http://localhost:8888/Article/saveOrUpdate"
        post(url,this.form).then(resp =>{

            // console.log(resp);
            // 提示
            this.$message({type:"success",message:resp.message})
            // 返回列表页面
            this.goBack();
        })
        },
        // 返回
        goBack(){
        this.$router.go(-1)
        }
    },
    created(){
        // 页面加载出来的时候，将路由中的参数拿到，放到this.form 中
        this.form = this.$route.query;
    }
}
</script>
<style lang="sass" scoped>

</style>